package com.excel;

import java.util.stream.Stream;

/**
 * @author yutao
 * @since 2020/4/30 2:23 下午
 */
public enum ExcelHeader {

    /**
     * 中药
     */
    ZHONGYAO_HEADER("中药", 13,
            new String[]{
                    "SKUID", "唯一编码", "药材", "剂型", "位置", "批号", "生产日期",
                    "有效期至", "当前数量", "盘点数量", "单位", "备注"},
            new String[]{
                    "skuId", "sn", "productName", "zyMedicineType", "location", "batchNo", "produceDate",
                    "validityDate", "remaining", "checkCount", "quantityUnitName", "comment"},
            new String[]{
                    "skuId", "sn", "name", "zyMedicineType", "location", "batchNo", "produceDate",
                    "validityDate", "remaining", "checkCount", "quantityUnitName", "comment"}),

    /**
     * 药品
     */
    MEDICINE_HEADER("药品", 10,
            new String[]{
                    "SKUID", "唯一编码", "通用名", "商品名", "位置", "规格", "厂家", "批号",
                    "生产日期", "有效期至", "当前数量", "拆零当前数量", "盘点数量",
                    "单位", "拆零盘点数量", "拆零单位", "备注"},
            new String[]{
                    "skuId", "sn", "name", "brand", "location", "spec", "vendor", "batchNo",
                    "produceDate", "validityDate", "remaining", "expectedTinyQuantity", "checkCount",
                    "quantityUnitName", "tinyQuantity", "tinyUnit", "comment"},
            new String[]{
                    "skuId", "sn", "name", "brand", "location", "spec", "vendor", "batchNo",
                    "produceDate", "validityDate", "remaining", "expectedTinyQuantity", "checkCount",
                    "quantityUnitName", "tinyQuantity", "tinyUnit", "comment"}),

    /**
     * 耗材
     */
    CONSUMABLE_HEADER("耗材", 11,
            new String[]{
                    "SKUID", "唯一编码", "标准名称", "位置", "规格", "厂家", "耗材分类", "计费类型", "单位",
                    "批号", "生产日期", "有效期至", "当前数量", "盘点数量", "备注"},
            new String[]{
                    "skuId", "sn", "name", "location", "spec", "vendor", "categoryName", "chargeTypeName",
                    "quantityUnitName", "batchNo", "produceDate", "validityDate", "remaining", "checkCount", "comment"},
            new String[]{
                    "skuId", "sn", "name", "location", "spec", "vendor", "categoryName", "chargeTypeName",
                    "quantityUnitName", "batchNo", "produceDate", "validityDate", "remaining", "checkCount", "comment"
            }),

    /**
     * 设备
     */
    DEVICE_HEADER("设备", 14,
            new String[]{
                    "SKUID", "唯一编码", "标准名称", "位置", "规格", "厂家", "设备分类", "计费类型", "单位",
                    "批号", "生产日期", "有效期至", "当前数量", "盘点数量", "备注"},
            new String[]{
                    "skuId", "sn", "name", "location", "spec", "vendor", "categoryName", "chargeTypeName",
                    "quantityUnitName", "batchNo", "produceDate", "validityDate", "remaining", "checkCount", "comment"},
            new String[]{
                    "skuId", "sn", "name", "location", "spec", "vendor", "categoryName", "chargeTypeName",
                    "quantityUnitName", "batchNo", "produceDate", "validityDate", "remaining", "checkCount", "comment"
            }),

    /**
     * 商品
     */
    PRODUCT_HEADER("商品", 15,
            new String[]{
                    "SKUID", "唯一编码", "标准名称", "位置", "规格", "厂家", "商品分类", "计费类型", "单位",
                    "批号", "生产日期", "有效期至", "当前数量", "盘点数量", "备注"},
            new String[]{
                    "skuId", "sn", "name", "location", "spec", "vendor", "categoryName", "chargeTypeName",
                    "quantityUnitName", "batchNo", "produceDate", "validityDate", "remaining", "checkCount", "comment"},
            new String[]{
                    "skuId", "sn", "name", "location", "spec", "vendor", "categoryName", "chargeTypeName",
                    "quantityUnitName", "batchNo", "produceDate", "validityDate", "remaining", "checkCount", "comment"
            });

    ExcelHeader() {
    }

    ExcelHeader(String name, Integer value, String[] headerName, String[] downloadField, String[] uploadField) {
        this.name = name;
        this.value = value;
        this.headerName = headerName;
        this.downloadField = downloadField;
        this.uploadField = uploadField;
    }

    public String getName() {
        return name;
    }

    public Integer getValue() {
        return value;
    }

    public String[] getHeaderName() {
        return headerName;
    }

    public String[] getDownloadField() {
        return downloadField;
    }

    public String[] getUploadField() {
        return uploadField;
    }

    /**
     * 名称
     */
    private String name;
    /**
     * 仓管类型
     */
    private Integer value;
    /**
     * 下载表头的中文名
     */
    private String[] headerName;
    /**
     * 下载表头字段名称  -- 利用反射获取值
     */
    private String[] downloadField;
    /**
     * 上传表头字段名称 -- 利用反射获取值
     */
    private String[] uploadField;

    public static ExcelHeader findType(Integer type) {
        return Stream.of(ExcelHeader.values()).filter(f -> f.getValue().equals(type)).findFirst().orElse(null);
    }

}
